﻿using System;
using System.Collections.Generic;
using MyAMS.WebServer.Models;
using MyAMS.WebServer.Repositories;

namespace MyAMS.WebServer.Services
{
    /// <summary>
    /// 节点服务
    /// </summary>
    public class NodeService : INodeService
    {
        private readonly INodeRepository nodeRepository;

        /// <summary>
        /// 初始化一个新的 <see cref="NodeService"/> 类的实例
        /// </summary>
        /// <param name="nodeRepository">节点仓库</param>
        public NodeService(INodeRepository nodeRepository)
        {
            this.nodeRepository = nodeRepository;
        }

        #region INodeService Members

        /// <summary>
        /// 获取所有节点
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Node> GetNodes()
        {
            return nodeRepository.Get();
        }

        /// <summary>
        /// 根据ID获取节点
        /// </summary>
        /// <param name="ID">节点ID</param>
        /// <returns>节点</returns>
        public Node Get(System.Guid ID)
        {
            return nodeRepository.Get(ID);
        }

        /// <summary>
        /// 根据地址获取指定节点
        /// </summary>
        /// <param name="uri">地址</param>
        /// <returns>节点</returns>
        public Node Get(Uri uri)
        {
            return new Node
            {
                ID = new Guid("00000000-0000-0000-0000-000000000000")
            };
        }

        #endregion
    }
}
